<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layuiAdmin 管理员 iframe 框</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${pageContext.request.contextPath }/back/layui/css/layui.css" media="all">
</head>
<body>

  <div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">登录名</label>
      <div class="layui-input-inline">
        <input type="text" id="adminName" name="loginname" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">密码</label>
      <div class="layui-input-inline">
        <input type="password" id="adminPwd" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">权限</label>
      <div class="layui-input-inline">
        <select name="role" id="adminPuis" lay-verify="required">
              	<option value="defult">请选择</option>
                <option value="1">管理员</option>
                <option value="2">超级管理员</option>
              </select>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">状态</label>
      <div class="layui-input-inline">
        <input type="checkbox"id="adminMark" value="1" checked name="switch" lay-skin="switch" lay-text="启用|禁用">
      </div>
    </div>
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-back-submit" value="确认">
    </div>
  </div>

  <script src="${pageContext.request.contextPath }/back/layui/layui.js"></script>
  <script>
  layui.config({
    base: '${pageContext.request.contextPath }/back/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var $ = layui.$
    ,form = layui.form ;
  })
  </script>
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script type="text/javascript">
    $(function() {
      //添加房间
      $("#LAY-user-back-submit").click(function () {
        var adminName=$("#adminName").val();
        var adminPwd= $("#adminPwd").val();
        var adminPuis=$("#adminPuis").val()*1;
        var adminMark=$("#adminMark")[0].checked;
        if(adminMark){
          adminMark=1;
        }else {
          adminMark=0;
        }
              $.ajax({
                type : "POST",
                url : "${pageContext.request.contextPath }/AdminsController/addAdmin",
                data : {
                  adminName:adminName,
                  adminPwd:adminPwd,
                  adminPuis:adminPuis,
                  adminMark:adminMark
                },
                dataType : "json",
                success : function(data) {
                  $("#adminName").val("");
                  $("#adminPwd").val("");
                }
              })

      })


    });
  </script>
</body>
</html>